/*
神经元层头文件
定义神经网络层的管理和操作
支持多层网络架构和层间连接
*/
#ifndef NEURON_LAYER_H
#define NEURON_LAYER_H

#include "Macros.h"
#include "Layer.h"
#include "Neuron.h"
#include <vector>
#include <memory>

using namespace std;

class NeuronLayer : public Layer {
public:
    NeuronLayer(int layerIndex, const LayerType& layerType, int numNeurons, int startNeuronId, const string& activationName = "sigmoid", const string& lossName = "mse");
    ~NeuronLayer();
    int getNumNeurons() const;
    int getStartNeuronId() const;
    const vector<shared_ptr<Neuron> >& getNeurons() const;
    const vector<double> getOutputs() const;
    const vector<double> getErrors() const;
    void forward(const vector<double>& inputs);
    void backward(const vector<double>& errors);
    void updateWeights(double learningRate);
    void updateWeights(double learningRate, double momentum);
    void updateBias(double learningRate);
    void updateBias(double learningRate, double momentum);
    void print() const;

private:
    int numNeurons;
    int startNeuronId;
    vector<shared_ptr<Neuron> > neurons;
};

#endif // NEURON_LAYER_H
